import {request} from "../../request/index"
import regeneratorRuntime from "../../lib/runtime/runtime";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs: [
      {
        id: 0,
        value: '商品收藏',
        isActive: true
      },
      {
        id: 1,
        value: '品牌收藏',
        isActive: false
      },
      {
        id: 2,
        value: '店铺收藏',
        isActive: false
      },
      {
        id: 3,
        value: '浏览足迹',
        isActive: false
      },
    ],
    collect: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let collect = wx.getStorageSync("collect") || [];
    this.setData({
      collect
    })
  },

  handleTabItemChange(e) {
    // console.log(e);
    //获取被点击的标题索引
    let {index} = e.detail;
    //修改原数组
    // console.log(this.data);
    let {tabs} = this.data
    tabs.forEach((v,i) => i==index?v.isActive=true:v.isActive=false)
    this.setData({
      tabs
    })
  },
})